package com.sen.design.pattern.creational.singleton;

/**
 * threadLocal单例：非全局单例，保持线程内单例
 */
public class ThreadLocalInstance {
    // 初始化单例类
    private static final ThreadLocal<ThreadLocalInstance> THREAD_LOCAL_INSTANCE_THREAD_LOCAL
            = ThreadLocal.withInitial(ThreadLocalInstance::new);
    private ThreadLocalInstance(){}

    public static ThreadLocalInstance getInstance(){
        return THREAD_LOCAL_INSTANCE_THREAD_LOCAL.get();
    }
}
